﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TCG.Engine.Effects;
using TCG.Engine.Core;
using TCG.Engine.Libraries;
using TCG.Engine.Impacts;

namespace TCG.Engine.Tests.HumanDeck
{
    [Effect("EyeForAnEye")]
    public class EyeForAnEyeEffect: OvertimeEffect
    {
        public EyeForAnEyeEffect(): base(1)
        {

        }

        public override void Apply(MoveContext mc)
        {
            mc.ActivePlayer.Effects.Add(this);
        }

        public override void Move(MoveContext mc)
        {
            if (duration != 0)
                return;

            var impacts = mc.Impacts.Where(i => i.Type == ImpactTypeInfo.DealDamage).Select(i => (SimpleImpact)i).Where(i => i.Target == TargerInfo.Enemy);

            foreach (var i in impacts.ToArray())
            {
                mc.Impacts.Add(ImpactsFactory.DealDamage(i.Value, TargerInfo.Self));
            }
        }
    }
}
